<?php

session_start();
include("../includes/conn.php");
$dbconn->admin_logincheck();
if($_GET['act']=='del'){
$id=intval($_GET['id']);
$dbconn->noretquery("delete from ".DBQIAN."rules where id=$id");
header("Location: rules.php?page=$_GET[page]");
};
$username = isset($_GET['title'])?$_GET['title']:'';
$time = isset($_GET['time'])?$_GET['time']:'';
$where = '1';
if($username)
{
	$where .= ' and '.DBQIAN.'rules.title=\''.$username.'\'';
}
if ($time)
{
	$where .= ' and '.DBQIAN.'rules.time>\''.$time.'\' and '.DBQIAN.'rules.time<\''.substr($time,0,10).' 23:59:59\'';
}

if($_GET['act']=='audit'){
$id=intval($_GET['id']);
$dbconn->noretquery("update ".DBQIAN."rules set status=1 where id=$id");
header("Location: rules.php?page=$_GET[page]");
};
if ($_GET['act'] == 'trucate')
{
	$dbconn->noretquery("delete from ".DBQIAN."rules");
	header("Location: rules.php");
}
echo '<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>欢迎登录后台管理系统</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<script language="JavaScript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-slide.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script>
$(document).ready(function(){
   $(function(){
   		$(\'#time\').datetimepicker();
      $(\'.rightinfo tbody tr:odd\').css("backgroundColor","#f5f8fa");
   });
});
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="index.php">首页</a></li>
    <li>规则说明</li>
  </ul>
</div>
<div class="rightinfo">
  <div class="tools"> 
    <ul class="toolbar">
    	 <li style="background:#FFF; text-indent:1em; border:0;margin-bottom:10px;">
      <form name="fsoso" method="get" action="">
        标题 <input type="text" name="title" value="';echo $_GET['title'];;echo '" class="dfinput" style="width:200px" />
   时间 <input type="text" name="time" id="time" value="';echo $_GET['time'];;echo '" placeholder="格式：2015-12-01" class="dfinput" style="width:200px" />
      <input name="submit" class="btn" value="查询" type="submit" >
      </form></li><br>
      <li><a href="rules_add.php"><span><img src="images/t01.png" /></span>添加</a></li> 
      <li><a onClick="if(confirm(\'您确认要清空吗？\')){location.href=\'?act=trucate\'}" href="#"><span><img src="images/t03.png" /></span>清空记录</a></li>

    </ul>
  </div><br/>
  <p style="height:15px;margin-bottom:10px;"></p>
  <table class="tablelist">
    <thead>
      <tr>
        <th width="10%">标题</th>
        <th width="9%">简介</th>
        <th width="7%">时间</th>
        <th width="10%">链接网址</th>
        <th width="10%">操作</th>
      </tr>
    </thead>
    <tbody>
      ';
$page = ($_GET['page'] == ''||!isset($_GET['page'])) ?1:$_GET['page'];
$pagesize=12;
$num=$dbconn->countn(DBQIAN."rules",$where);
$pagelist = new page($page,$pagesize,$num ,10,2,0);
$query=$dbconn->news_list(" select * from ".DBQIAN."rules where ". $where ." order by id desc ",$page,$pagesize);
while($row=$dbconn->fetch($query)){
;echo '<tr height="45">
        <td>';echo $row['title'];echo '</td>
        <td>';echo $row['desc'];;echo '</td>
        <td>';echo $row['time'];;echo '</td>
         <td>';echo $row['url'];;echo '</td>
        <td>
          <img src="images/t03.png" width="14"> 
          <a onClick="if(confirm(\'您确认要删除吗？\')){window.location.href=\'?act=del&id=';echo $row['id'];echo '&page=';echo $page;echo '\'}" href="#" class="tablelink">删除</a>
        <img src="images/ice1.png" width="14">
        <a onClick="if(confirm(\'您确认要编辑吗？\')){window.location.href=\'rules_edit.php?act=edit&id=';echo $row['id'];echo '&page=';echo $page;echo '\'}" href="#" class="tablelink">编辑</a>';
        echo '</td>
      </tr>
          ';
}
;echo '    </tbody>
  </table>
</div>
<div style=" width:90%; padding:10px 0 10px 0; text-align:center">
  ';if($num!=0) echo $pagelist->showpages();else echo "<font color='#ff0000'>暂无数据</font>";;echo '</div>
</body>
</html>'
?>